import { lazy } from 'react';
import { RouteObject } from 'react-router-dom';
import { Navigate } from 'react-router-dom';
import AdminWrapper from '@/components/AdminWrapper';
import AuthWrapper from '@/components/AuthWrapper';
import RxLazy from '@/components/RxLazy';

const Admin = lazy(() => import('@/pages/Admin'));
const CategoryManage = lazy(() => import('@/pages/Admin/CategoryManage'));
const GoodsManage = lazy(() => import('@/pages/Admin/GoodsManage'));
const SlideManage = lazy(() => import('@/pages/Admin/SlideManage'));
const UserManage = lazy(() => import('@/pages/Admin/UserManage'));

export default [
  {
    path: '/admin',
    element: (
      <RxLazy>
        <AuthWrapper>
            <Admin />
        </AuthWrapper>
      </RxLazy>
    ),
    children: [
      {
        path: '',
        element: <Navigate to={'/admin/user_manage'} replace />,
      },
      {
        path: 'user_manage',
        element: (
          <RxLazy>
            <UserManage />
          </RxLazy>
        ),
      },
      {
        path: 'category_manage',
        element: (
          <RxLazy>
            <CategoryManage />
          </RxLazy>
        ),
      },
      {
        path: 'goods_manage',
        element: (
          <RxLazy>
            <GoodsManage />
          </RxLazy>
        ),
      },
      {
        path: 'slide_manage',
        element: (
          <RxLazy>
            <SlideManage />
          </RxLazy>
        ),
      },
    ],
  },
] as RouteObject[];
